package com.tgh.au.c5;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.graphics.drawable.shapes.PathShape;
import android.graphics.drawable.shapes.RectShape;
import android.view.View;

public class GameView3 extends View {
	ShapeDrawable shapeDrawable;
	public GameView3(Context context) {
		super(context);
	}
	public void drawShape(Canvas canvas){
		//实例化一个ShapeDrawable并说明绘制对象是一个矩形
		shapeDrawable=new ShapeDrawable(new RectShape());
		shapeDrawable.getPaint().setColor(Color.RED);
		//设置图像显示的区域
		Rect bounds=new Rect(5, 250, 55, 280);
		shapeDrawable.setBounds(bounds);
		shapeDrawable.draw(canvas);
		
		shapeDrawable=new ShapeDrawable(new OvalShape());
		shapeDrawable.getPaint().setColor(Color.GREEN);
		shapeDrawable.setBounds(70, 250, 150, 280);
		shapeDrawable.draw(canvas);
		
		Path path=new Path();
		path.moveTo(150+5,80+80-50);
		path.lineTo(150+45, 80+80-50);
		path.lineTo(150+30, 80+120-50);
		path.lineTo(150+20, 80+120-50);
		path.close();
		shapeDrawable=new ShapeDrawable(new PathShape(path, 150, 150));
		shapeDrawable.getPaint().setColor(Color.BLUE);
		shapeDrawable.setBounds(100, 170, 200, 280);
		shapeDrawable.draw(canvas);
	}
}
